package com.chaucer.demo.config;

import com.chaucer.demo.datasource.DynamicDataSourceAutoConfiguration;

//import com.chaucer.demo.transmit.ForwardRequestInterceptor;
import com.chaucer.demo.transmit.ForwardRequestInterceptor;
import com.chaucer.demo.transmit.ReceiveHandlerFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import({
        DynamicDataSourceAutoConfiguration.class,
})
public class RouteAutoConfiguration {

    @Bean
    public FilterRegistrationBean receiveHandleFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean(new ReceiveHandlerFilter());
        registration.addUrlPatterns("/*");
        registration.setOrder(1);
        return registration;
    }


    @Bean
    public ForwardRequestInterceptor forwardRequestInterceptor() {
        return new ForwardRequestInterceptor();
    }
}
